// 删除用户
function deleteUser(userId) {
    $("#deleteUserModal").modal({
        keyboard: false
    });
    $("#deleteUserBtn").on("click", function () {
        if (userId != null && userId.length != null) {
            $.ajax({
                type: "POST",
                url: "/userManage/deleteUser",
                data: {userId: userId},
                dataType: "json",
                success: function (data) {
                    if (data.result == "success") {
                        window.location.reload();
                    } else {
                        alert("BUG：删除用户失败");
                    }
                },
                error: function () {
                    $(".user-message").html("ajax 服务器错误").css({"color": "red"});
                }
            });
        }
    });
}

// 回车搜索用户
function onKeyDownUser(event) {
    var e = event || window.event || arguments.callee.caller.arguments[0];
    if (e && e.keyCode == 13) {
        var content = $.trim($(".searchContentUser").val());
        if (content == null || content.length != 0) {
            window.location.href = "/userManage/searchUser?content=" + content;
        } else {
            alert("搜索条件不能为空呦");
        }
    }
}

// 按钮搜索用户
$(".searchBtnUser").on("click", function () {
    var content = $.trim($(".searchContentUser").val());
    if (content == null || content.length != 0) {
        window.location.href = "/userManage/searchUser?content=" + content;
    } else {
        alert("搜索条件不能为空呦");
    }
});